export default {
  userName: [
    {required: true, trigger: 'blur', message: '手机号不能为空！'},
    {
      pattern: /^1([38][0-9]|4[014-9]|[59][0-35-9]|6[2567]|7[0-8])\d{8}$/,
      trigger: 'blur',
      message: '请输入正确的手机号！'
    }
  ],
  realName: [
    {required: true, trigger: 'blur', message: '姓名不能为空！'},
    {min: 2, max: 10, trigger: 'blur', message: '姓名长度为2-10位！'},
    {pattern: /^[\u4e00-\u9fa5]{2,10}$/, trigger: 'blur', message: '姓名只能包含中文字符！'}
  ],
  phone: [
    {required: true, trigger: 'blur', message: '手机号不能为空！'},
    {
      pattern: /^1([38][0-9]|4[014-9]|[59][0-35-9]|6[2567]|7[0-8])\d{8}$/,
      trigger: 'blur',
      message: '请输入正确的手机号！'
    }
  ],
  password: [
    {required: true, trigger: 'blur', message: '登录密码不能为空！'},
    {min: 6, max: 20, trigger: 'blur', message: '密码长度为6-20位！'},
    {pattern: /^[a-zA-Z0-9_]+$/, trigger: 'blur', message: '密码只能包含字母、数字和下划线！'}
  ],
  idCard: [
    {required: true, message: '请输入身份证号', trigger: 'blur'},
    {
      pattern: /(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$)/,
      message: '证件号码格式有误！',
      trigger: 'blur'
    }
  ],
  deptId: [
    {required: true, message: '请选择部门', trigger: ['blur', 'change']},
    {
      validator: (rule, value, callback) => {
        if (!value) {
          callback(new Error('请选择部门'));
        } else if (value === '0') {
          callback(new Error('请选择部门'));
        } else {
          callback();
        }
      }, trigger: ['blur', 'change']
    }
  ],
  companyName: [{required: true, message: '请输入单位名称', trigger: 'blur'}],
  jobType: [{required: true, message: '请输入工种/岗位', trigger: 'blur'}],
  workArea: [{required: true, message: '请输入作业区域', trigger: 'blur'}],
  entryTime: [{required: true, message: '请选择进厂时间', trigger: 'change'}],
  leaveTime: [{required: true, message: '请选择离厂时间', trigger: 'change'}],

  'licenses.name': [{required: true, message: '请输入证书名称', trigger: 'blur'}],
  'licenses.number': [{required: false, message: '请输入号码', trigger: 'change'}],
  'licenses.type': [{required: true, message: '请选择证书', trigger: 'change'}],
  'licenses.project': [{required: true, trigger: 'change'}],
}
